import time

from selenium import webdriver

from .switch import Switch
from ...common.ui.Selector import Selector


def test_switch_antd3x():
    browser = webdriver.Chrome()
    browser.maximize_window()
    browser.get("https://3x.ant.design/components/switch-cn/")

    # 基本
    switch = Switch(browser,
                    '//section[@id="components-switch-demo-basic"]/section/button[contains(@class,"ant-switch")]',
                    Selector.XPATH)
    switch.setValue('on')
    assert True == switch.getValue()

    switch.setValue()
    assert False == switch.getValue()

    # 一组
    switch = Switch(browser,
                    '(//section[@id="components-switch-demo-text"]/section/div/button[contains(@class,"ant-switch")])[1]',
                    Selector.XPATH)
    switch.setValue('开')
    assert True == switch.getValue()
    switch.setValue('off')
    assert False == switch.getValue()
